/*******************************************************************************
 * Copyright (c) 2008 Smart Mai(smardio@gmail.com).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Contributors:
 *     Smart Mai(smardio@gmail.com) - initial API and implementation
 ******************************************************************************/
package com.smartdio.company.model;

import java.util.Vector;

/**
 * @author smart
 * 
 */
public class Company {

	public String name;//企业的名称
	public long id;//企业的唯一ID
	public String description;//企业的说明
	public String address;//企业的通讯地址
	public String phone1;//企业的电话
	public String phone2;//企业的电话

	private Vector<Department> departments;//关联下级的部门

	private Vector<Person> personnels;//关键所有职员

	/**
	 * 
	 */
	public Company() {

		departments = new Vector<Department>();

		personnels = new Vector<Person>();
	}

	/**
	 * 构造Company对象的同时，建立各个字段的演示数据
	 * 
	 * @param demoData
	 */
	public Company(boolean demoData) {
		this();
		if (demoData)
			createDemoData();
	}

	/**
	 * 建立演示数据
	 */
	private void createDemoData() {
		name = "A Company";
		description = "Description about this Company.";
		address = "Company location";
		phone1 = "0123456";
		phone2 = "0123466";
	}

	/**
	 * 每新建一个Department，都会调用这个方法，添加到departments中。
	 * @param dep
	 */
	void addDepartment(Department dep) {
		departments.add(dep);
	}
	
	/**
	 * 删除指定的department
	 * @param dep
	 */
	void removeDepartment(Department dep){
		departments.remove(dep);
	}

	/**
	 * 获得所有下级部门
	 * @return
	 */
	public Vector<Department> getDepartments() {
		return departments;
	}


	/**
	 * 每新建一个Personnel对象，都添加到personnels中，以建立关联
	 * @param p
	 */
	void addPersonnel(Person p) {
		personnels.add(p);
	}

	/**
	 * 删除关联的Personnel对象。
	 * @param p
	 */
	void removePersonnel(Person p) {
		personnels.remove(p);
	}

	/**
	 * 获得所有职员。
	 * @return
	 */
	public Vector<Person> getPersonnels() {
		return personnels;
	}

}
